package com.itheima.dao;

import com.github.pagehelper.Page;
import com.itheima.domain.Menu_management;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface Menu_managementDao {
    @Select("select * from t_menu")
    List<Menu_management> findAll();
    @Select("select * from t_menu where id = #{userId}")
    Menu_management findById(Integer userId);
    @Update({"update user set name=#{name},linkUrl=#{linkUrl},path=#{path},priority=#{priority},description=#{description},parentMenuId=#{parentMenuId},icon=#{icon},level=#{level}"})
    void updateMenu(Menu_management menu);
    @Select("insert into t_menu values(null,#{name},#{linkUrl},#{path},#{priority},#{description},#{parentMenuId},#{icon},#{level})")
    void save(Menu_management menu_management);
    @Delete("delete from t_menu where id = #{id}")
    void deleteById(Integer id);
    @Update({"update `t_menu`  set name=#{name},linkUrl=#{linkUrl},path=#{path},priority=#{priority},description=#{description},parentMenuId=#{parentMenuId},icon=#{icon},level=#{level} where id = #{id}"})
    void edit(Menu_management menu_management);

    Page<Menu_management> selectByCondition(String queryString);

    @Select("<script>" +
            "select * from t_menu\n" +
            "<if test=\"value != null and value.length > 0\">\n" +
            "where code like concat(concat('%',#{value}),'%') or name like concat(concat('%',#{value}),'%') or id like concat(concat('%',#{value}),'%')\n" +
            "</if>" +
            "</script>")
    List<Menu_management> EstimateFindAll();
}
